import pandas as pd

data = {
    "name": ["lili","Mark","Jack","Tom"],
    "age": [18,19,20,21],
}
df = pd.DataFrame(data)

#  方法1: df.columns.tolist()
print(df.columns.tolist())
'''
['name', 'age']
'''

# 方法2: df.keys()
print(df.keys())
print(list(df.keys()))
'''
Index(['name', 'age'], dtype='object')
['name', 'age']
'''